package com.blork.sowidget;

import static android.provider.BaseColumns._ID;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class QuestionData extends SQLiteOpenHelper{
	
	private static final String DATABASE_NAME = "questions.db";
	private static final int DATABASE_VERSION = 5; 
	
	/** Create a helper object for the Events database */
	public QuestionData(Context ctx){
		super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db){
		db.execSQL("CREATE TABLE questions (" 
				+_ID+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
						"q_id TEXT," +
						"title TEXT," +
						"tags TEXT," +
						"votes TEXT," +
						"answer_count TEXT," +
						"user_name TEXT);");
	}
	

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		db.execSQL("DROP TABLE IF EXISTS questions");
		onCreate(db);
	}
}
//"questions": [
//              {
//                "tags": [
//                  "sql",
//                  "database",
//                  "theory",
//                  "normalization"
//                ],
//                "answer_count": 6,
//                "accepted_answer_id": 3075463,
//                "favorite_count": 0,
//                "question_timeline_url": "/questions/3075416/timeline",
//                "question_comments_url": "/questions/3075416/comments",
//                "question_answers_url": "/questions/3075416/answers",
//                "question_id": 3075416,
//                "owner": {
//                  "user_id": 370999,
//                  "user_type": "unregistered",
//                  "display_name": "R Brooks",
//                  "reputation": 18,
//                  "email_hash": "d1c1dae3900aa3c4b37655873b4b993a"
//                },
//                "creation_date": 1276949328,
//                "last_activity_date": 1276954789,
//                "up_vote_count": 3,
//                "down_vote_count": 0,
//                "view_count": 77,
//                "score": 3,
//                "community_owned": false,
//                "title": "Is it bad to not use normalised tables in this database?"
//              },